package com.consume.bhy.entity;

import java.util.List;

public class PageEntity <T>{

	// 结果集
	private T data;
	// 记录数
	private int totalRecords;
	// 每页多少条数据
	private int pageSize=10;
	// 第几页
	private int pageNo;
	
	private List<String> classList;
	
	
	public List<String> getClassList() {
		return classList;
	}

	public void setClassList(List<String> classList) {
		this.classList = classList;
	}


	//	总页数
	public int getTotalPage() {
		int totalPage = (int)Math.ceil((double)totalRecords/pageSize);

		//当无数据时设置页数为1
		if(totalPage == 0) {
			totalPage = 1;
		}
		return totalPage;	
	}


	//拓展字段
	private String searchPositionName;
	private String searchTimeStart;
	private String searchTimeEnd;
	
	private int searchCondition;
	
	
	public int getSearchCondition() {
		return searchCondition;
	}

	public void setSearchCondition(int searchCondition) {
		this.searchCondition = searchCondition;
	}

	public String getSearchPositionName() {
		return searchPositionName;
	}

	public void setSearchPositionName(String searchPositionName) {
		this.searchPositionName = searchPositionName;
	}

	public String getSearchTimeStart() {
		return searchTimeStart;
	}

	public void setSearchTimeStart(String searchTimeStart) {
		this.searchTimeStart = searchTimeStart;
	}

	public String getSearchTimeEnd() {
		return searchTimeEnd;
	}

	public void setSearchTimeEnd(String searchTimeEnd) {
		this.searchTimeEnd = searchTimeEnd;
	}

	
	
	
	public int getFirst() {
		
		return 1;
	}
	
	public int getLast() {
		
		return getTotalPage();
	}
	
	public int getPre() {
		if(pageNo == 1) {
			return 1;
		}
		
		return pageNo-1;	
	}
	
	public int getNext() {
		
		if(pageNo == getTotalPage()){
			return pageNo;
		}
		
		return pageNo+1;
	}

	//封装
	public T getData() {
		return data;
	}

	@SuppressWarnings("unchecked")
	public void setData(List<ShowEntity> list) {
		this.data = (T) list;
	}

	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}
	
	
	
	
	
}
